
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using StudentVideo.Shared.Enums;

namespace StudentVideo.Data.Entities;

/// <summary>
/// 角色表
/// </summary>
[Table("role")]
public class RoleEntity: BaseEntity {

   /// <summary>
   /// 角色名称
   /// </summary>
   [Required]
   [MinLength(1)]
   [MaxLength(20)]
   public required string Name { get; set; }

   /// <summary>
   /// 是否启用
   /// </summary>
   public bool Enable { get; set; } = true;

   /// <summary>
   /// 角色类型
   /// </summary>
   [Column(TypeName = "tinyint")]
   public RoleTypeEnum Type { get; set; } = RoleTypeEnum.Ordinary;

   /// <summary>
   /// 描述
   /// </summary>
   [MaxLength(255)]
   public string? Description { get; set; }

   [InverseProperty(nameof(RolePermissionMapEntity.Role))]
   public ICollection<RolePermissionMapEntity>? RolePermissionMaps { get; set; }

   [InverseProperty(nameof(RoleSystemMenuMapEntity.Role))]
   public ICollection<RoleSystemMenuMapEntity>? RoleSystemMenuMap { get; set; }

   [InverseProperty(nameof(UserRoleMapEntity.Role))]
   public ICollection<UserRoleMapEntity>? UserRoleMaps { get; set; }
}
